import numpy as np
import pandas as pd
import pymysql
import sqlalchemy
from sqlalchemy import create_engine
print(sqlalchemy.__version__)
print(pymysql.__version__)
pymysql.install_as_MySQLdb()

df = pd.DataFrame({
    "班级":["一年级","二年级","三年级","四年级"],
    "男生人数":[25,23,27,30],
    "女生人数":[19,17,20,20]
})
print(df)

engine = create_engine('mysql+pymysql://root:201008Wrl@127.0.0.1:3306/info?charset=utf8')
df.to_sql('students', con = engine, if_exists='replace',index=False)

import numpy as np
import pandas as pd
data = np.arange(12).reshape((3,4))
df3 = pd.DataFrame(data,index=['d','b','c'],columns=['dd','aa','cc','bb'])
print(df3)
df3.sort_index(axis=0)  #行排序
df3.sort_index(axis=1)  #列排序
df3.sort_values(by='cc')#按’cc’列的数据进行排序